package cn.iocoder.yudao.module.lfd.dal.mysql.customer;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.lfd.dal.dataobject.customer.CustomerDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.lfd.controller.admin.customer.vo.*;

/**
 * 顾客 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CustomerMapper extends BaseMapperX<CustomerDO> {

    default PageResult<CustomerDO> selectPage(CustomerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerDO>()
                .eqIfPresent(CustomerDO::getOpenid, reqVO.getOpenid())
                .likeIfPresent(CustomerDO::getPhone, reqVO.getPhone())
                .betweenIfPresent(CustomerDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(CustomerDO::getNickName, reqVO.getNickName())
                .eqIfPresent(CustomerDO::getIntegral, reqVO.getIntegral())
                .eqIfPresent(CustomerDO::getMoney, reqVO.getMoney())
                .orderByDesc(CustomerDO::getId));
    }

    default List<CustomerDO> selectList(CustomerExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<CustomerDO>()
                .eqIfPresent(CustomerDO::getOpenid, reqVO.getOpenid())
                .likeIfPresent(CustomerDO::getPhone, reqVO.getPhone())
                .betweenIfPresent(CustomerDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(CustomerDO::getNickName, reqVO.getNickName())
                .eqIfPresent(CustomerDO::getIntegral, reqVO.getIntegral())
                .eqIfPresent(CustomerDO::getMoney, reqVO.getMoney())
                .orderByDesc(CustomerDO::getId));
    }

}
